define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'work/index' + location.search,
                    add_url: 'work/add',
                    edit_url: 'work/edit',
                    del_url: 'work/del',
                    multi_url: 'work/multi',
                    table: 'work',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'user.username', title: __('User.username')},
                        {field: 'title', title: __('Title')},
                        {field: 'jgg_db_num', title: __('Jgg_db_num')},
                        {field: 'jgg_dg_num', title: __('Jgg_dg_num')},
                        {field: 'jgg_zg_num', title: __('Jgg_zg_num')},
                        {field: 'jgg_xg_num', title: __('Jgg_xg_num')},
                        {field: 'fgg_db_num', title: __('Fgg_db_num')},
                        {field: 'fgg_dg_num', title: __('Fgg_dg_num')},
                        {field: 'fgg_zg_num', title: __('Fgg_zg_num')},
                        {field: 'fgg_xg_num', title: __('Fgg_xg_num')},
                        {field: 'dg_db_num', title: __('Dg_db_num')},
                        {field: 'dg_dg_num', title: __('Dg_dg_num')},
                        {field: 'dg_zg_num', title: __('Dg_zg_num')},
                        {field: 'dg_xg_num', title: __('Dg_xg_num')},
                        {field: 'cs_db_num', title: __('Cs_db_num')},
                        {field: 'cs_dg_num', title: __('Cs_dg_num')},
                        {field: 'cs_zg_num', title: __('Cs_zg_num')},
                        {field: 'cs_xg_num', title: __('Cs_xg_num')},
                        {field: 'address', title: __('Address')},
                        {field: 'work_time', title: __('Work_time'), operate:'BETWEEN'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});